import java.util.Scanner;

public class BiggestDividor {
    public static void main(String[] args) {
        Scanner scanner = new Scanner (System.in);
        int num1 = scanner.nextInt();
        int num2 = scanner.nextInt();
        int min = Math.min(num1,num2);
        int i=0;
        for(i=min;i>1;i--){
            if(num1%i==0&&num2%i==0){
                System.out.println(i);
                break;
            }
        }
        scanner.close();
    }
}
